﻿using UnityEngine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.painting;
using System.Collections.Generic;
using System.Linq;

public class Test_UIWidgets_2 : UIWidgetsPanel
{
    protected override Widget createWidget()
    {
        return new ToDo();
    }

    class ToDo : StatefulWidget
    {
        public override State createState()
        {
            return new ToDoState();
        }
    }

    class ToDoState : State<ToDo>
    {

        private List<string> m_strs = new List<string>()
        {
            "The Fucking world",
            "Fuck world again",
            "Fuck world again and again",
        };

        private Widget[] ToDoList
        {
            get { return m_strs.Select(data => GetDefultContainer()).ToArray(); }
        }

        public override Widget build(BuildContext context)
        {
            return new ListView(
               children: new List<Widget>()
               {
                new GestureDetector(
                    child: new Container(
                                child: new Text(data:"+", style: new TextStyle(fontSize:30)),
                                alignment: Alignment.center
                            ),
                    onTap:()=>
                    {
                        Debug.Log("Pass");
                        setState(() =>
                        {
                            m_strs.Add("HAK DSZ");
                        });
                    }
                )
               },
               padding: EdgeInsets.only(top: 50)
           ); ;
        }

        private Widget GetDefultContainer()
        {
            return new Container(
                    child: new Text(data: "Fucking world", style: new TextStyle(fontSize: 30)),
                    alignment: Alignment.center
                );
        }
    }
}
